package com.levenx.utils;

import com.levenx.error.exceptions.CoreException;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormatUtils {

    public static final String PATTERN_SIMPLE_DATE = "yyyy-MM-dd";

    public static final String STYLE_yyyyMMdd = "yyyyMMdd";

    public static final String STYLE_FULL = "yyyy-MM-dd HH:mm:ss";


    public static final Date parse(String time, String pattern){
        try {
            return (new SimpleDateFormat(pattern)).parse(time);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static final String format(Date time, String pattern){
        return (new SimpleDateFormat(pattern)).format(time);
    }

}
